package com.utils.erweima.zxing;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class Test {
	public static void main(String[] args) {
		int width = 300;
		int height = 300;
		String format = "png";
		Map<Object, Object> map = new HashMap<Object, Object>();
		//文字编码
		map.put(EncodeHintType.CHARACTER_SET, "utf-8");
		try {
			BitMatrix bitMatrix = new MultiFormatWriter().encode("http://172.20.10.4:8080/login?method=toLoginPage", BarcodeFormat.QR_CODE, width, height);
			MatrixToImageWriter.writeToFile(bitMatrix, format, new File("C:\\Users\\panpa\\Desktop/zxing.png"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}
